<?php

/**
 * phpFoX API
 *
 * @package Api_phpFoX
 * @author Raymond Benc aka natio <www.raybenc.com>
 * @copyright Copyright (c) phpFoX Limited
 */
class Api_phpFoX
{
	/**
	 * Initiate Class
	 * @param array $aArgs Mixed arguments passed in an array
	 */
	function Api_phpFoX($aArgs = array())
	{
		/**
		 * Define the full location to where the phpFoX Init file is located.
		 * @package Api_phpFoX
		 */
		define("coreDir", dirname(dirname(dirname(dirname(__FILE__)))) . "/");

		if ( isset($aArgs['init_no_session']) )
		{
			/**
			 * Make sure we don't set a session
			 */
			define("bNoSession", true);
		}

		if ( isset($aArgs['init_no_debug']) )
		{
			/**
			 * Make sure not to use our debug
			 */
			define("bNoDebugMode", true);
		}

		if ( isset($aArgs['init_no_smarty']) )
		{
			/**
			 * Make sure not to load SMARTY
			 * Handy if another product loads SMARTY before we do
			 */
			define("bNoSmarty", true);
		}

		/**
		* Location of the phpFoX INIT
		*/
		$sInitFile = coreDir . "include/init.inc.php";

		if ( !file_exists($sInitFile) )
		{
			/**
			 * We need to exit the routine because we can't find the INIT file
			 */
			exit('Can\t load phpFoX Init File: '. $sInitFile .'');
		}

		/**
		 * Require the heart init file of phpFoX
		 */
		require_once coreDir . "include/init.inc.php";
	}

	#################################################################
	#
	# OBJECTS / CLASSES / FUNCTIONS
	#
	#################################################################


	#################################################################
	#
	# SETTINGS
	#
	#################################################################

	/**
	 * Gets settings from sys_set table and include/settings/common.sett.php
	 *
	 * @param mixed $mParam Name of setting if its a string. Can also be an array incase we have a prefix
	 * @return string Value of the setting
	 *
	 */
	function GetParam($mParam)
	{
		return App::getParam($mParam);
	}

	#################################################################
	#
	# LANGUAGE
	#
	#################################################################

	/**
	 * Get all language variables
	 *
	 * @return array All variables set by language class
	 */
	function GetLanguageDetails()
	{
		$oLang = &App::getLanguage();
		return $oLang->aLanguage;
	}

	/**
	 * Get phrase from core language package
	 *
	 * @param string $sVar Variable name
	 * @param array $aParams Extra params for printf
	 * @return string Phrase
	 */
	function Format($sVar, $aParams = array())
	{
		return App::format($sVar, $aParams);
	}

	#################################################################
	#
	# USER / MEMBERSHIP
	#
	#################################################################

	/**
	 * Gets any details for a user
	 * @example $obj->getUser('id') Will return the users ID
	 * @param string $sVar Field we need to return
	 * @return mixed Returns valid user details such as: Username, UserID, Password, Email etc...
	 */
	function getUser($sVar)
	{
		return App::getUser($sVar);
	}

	/**
	 * Only allow members in a specific area
	 * @return mixed If they are not a user it will redirect them to the phpFoX login page
	 */
	function membersOnly()
	{
		return App::membersOnly();
	}
}

?>